<template>
  <view class="zdybox">
    <view>
    			
    				<view class="addzdy-box">

              <view class="" style="width: 90%;margin: 20rpx auto 0 auto;">
                <view class="inpbox" >
                  名称：<input class="addinput" v-model="addzdy.title" type="text" :placeholder="tid == 9999 ? '例如：商业计划与报告' : '例如: 策划高手'"/>
                </view>
                <view  class="txtbox"  >
                  简介：<textarea class="jjinput"  v-model="addzdy.description" type="text" :placeholder=" tid == 9999 ?'例如: 商业策划专家，快速创作各种商业文案。' :  '例如: 我是策划高手，擅长提供定制化策划和建议。'"/>
                </view>
                <view class="txtbox"  >
                  定义：<textarea class="addtxt" v-model="addzdy.command" :placeholder="tid == 9999 ? ' 例如: 请模拟一个“商业策划专家”，擅长创作各种商业文案。' : '例如: 请扮演一个“策划专家”，特别擅长为各种不同规模和领域的企业或机构提供定制化的策划建议。'" name="" id="" cols="30" rows="10"></textarea>
                </view>
                <view class="btn-box">
                 
                 <button class="zdybtn1" @click="btnok">确定</button>
                 
                </view>
              </view>
    				</view>
    	
    		</view>
  </view>
</template>

<script>
  export default {
    onLoad(e) {
      console.log(e);
      uni.setNavigationBarTitle({
        title:e.title
      })
      this.tid = e.id
    },
    data() {
      return {
        tid:'',
        addzdy:{
          'title':'',
          'description':'',
          'command':''
        },
      }
    },
    methods:{
      btnok() {
        uni.request({
                	url: getApp().globalData.apiDomain+'/airole/addairole',
                	method: 'POST',
                	header: {
                		'content-type': 'application/x-www-form-urlencoded', //自定义请求头信息
                		'token': uni.getStorageSync('wbyun_token'),
                    'wbapp':'weixin_mp_xbgy'
                	},
                	data: {
                    'tid':this.tid ,
                    'title': this.addzdy.title,
                    'description': this.addzdy.description,
                    'command': this.addzdy.command,
                  },
                	dataType: 'json',
                	success:  res => {
                    console.log(res,'123');
                		if (res['data']['code'] == 200) {
                      uni.showToast({
                      	title: res['data']['msg'],
                      	icon: 'none'
                      });
                      this.addzdy ={
                        'title':'',
                        'description':'',
                        'command':''
                      }
                      setTimeout(() => {
                        uni.navigateBack({
                          delta: 1 // 表示返回上一页
                        });
                      },1000)
                			return;
                		}else { 
                			uni.showToast({
                				title: res['data']['msg'],
                				icon: 'none'
                			});
                		}
                	},
                	fail: () => {},
                	complete: () => {
                	}
                });
      },
    
    }
  }
</script>

<style>
  .zdybox {
    width: 95%;
    height: 900rpx;
    background-color: #fff;
    margin: 50rpx auto 0 auto;
    padding-top: 50rpx;
  }
  .inpbox {
    display: flex;
    margin: 10rpx 0;
    align-items: center;
    margin-bottom: 25rpx;
  }
  .txtbox {
    display: flex;
    margin: 10rpx 0 30rpx 0;
  }
  .addinput {
    width: 400rpx;
    height: 80rpx;
    padding: 5rpx 10rpx 5rpx 20rpx;
    border: 0;
    background-color: #f7f7f7;
    flex: 1;
    
  }
  .jjinput {
    flex: 1;
    padding: 20rpx;
    background-color: #f7f7f7;
    height: 200rpx;
    border: 0;
  }
  .addtxt {
    flex: 1;
    height: 240rpx;
    line-height: 35rpx;
    border: 0;
    background-color: #f4f4f4;
    padding: 20rpx;
  }
  .btn-box {
    display: flex;
    }
    .zdybtn1 {
      width: 100%;
      height: 80rpx;
      line-height: 80rpx;
      color: #fff;
      border: 0;
      font-size: 30rpx;
      margin-top: 30rpx;
    }
    .zdybtn1 {
      background-color: #04BABE;
    }

</style>